//
//  PayModule.m
//  xmgjAppFront
//
//  Created by Zeki on 2020/7/17.
//  Copyright © 2020 guojutech. All rights reserved.
//

#import "PayModule.h"
#import <Foundation/Foundation.h>
#import <AlipaySDK/AlipaySDK.h>
#import "WXApi.h"

@implementation PayModule
RCT_EXPORT_MODULE();
//微信支付

RCT_EXPORT_METHOD(wxPay:(NSDictionary *)payParam){
  dispatch_async(dispatch_get_main_queue(), ^{
    //调起微信支付
    PayReq* req             = [[PayReq alloc] init];
    req.partnerId           = [payParam objectForKey:@"partnerid"];
    req.prepayId            = [payParam objectForKey:@"prepayid"];
    req.nonceStr            = [payParam objectForKey:@"noncestr"];
    req.timeStamp           = [[payParam objectForKey:@"timestamp"] intValue];
    req.package             = [payParam objectForKey:@"package"];
    req.sign                = [payParam objectForKey:@"sign"];
    [WXApi sendReq:req completion:^(BOOL success) {
      
    }];
  });
}

//支付宝支付
RCT_EXPORT_METHOD(aliPay:(NSString *)orderString){
  dispatch_async(dispatch_get_main_queue(), ^{
    [[AlipaySDK defaultService] payOrder:orderString fromScheme:@"xmgjtechiOSAPP" callback:^(NSDictionary *resultDic) {
      GJLog(@"alipayCallBack%@",resultDic);
    }];
  });
}


@end
